package org.springframework.beanFactoryPostProcessor;

import org.springframework.beanFactoryPostProcessor.config.BeanFactoryPostProcessorConfig;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

/**
 * @Author: T-jack
 * @Date: 2024-01-09-10:48
 * @Description:
 */
public class BeanFactoryPostProcessorMain {

	public static void main(String[] args) {
		new BeanFactoryPostProcessorMain().base();
	}

	public void base() {
		// ⬇️GenericApplicationContext 是一个【干净】的容器，默认不会添加任何后处理器，方便做测试
		GenericApplicationContext context = new GenericApplicationContext();

		context.registerBean("config", BeanFactoryPostProcessorConfig.class);

		// 添加Bean工厂后处理器ConfigurationClassPostProcessor
		// 解析@ComponentScan、@Bean、@Import、@ImportResource注解
		context.registerBean(ConfigurationClassPostProcessor.class);
		// ⬇️初始化容器
		context.refresh();

		for (String name : context.getBeanDefinitionNames()) {
			System.out.println(name);
		}

		// ⬇️销毁容器
		context.close();
	}

	public void baseScan(){

	}


}
